#!/usr/bin/env python
# -*- coding:utf8 -*-
# uncompyle6 version 2.15.1
# Python bytecode 2.7 (62211)
# Decompiled from: Python 2.7.10 (default, Jul  1 2017, 13:36:56) 
# [GCC 4.4.6 20110731 (Red Hat 4.4.6-4)]
# Embedded file name: ./esb/components/generic/apis/weixin_qy/get_token.py
# Compiled at: 2017-11-16 15:44:28
from django import forms
from components.component import Component, SetupConfMixin
from common.forms import BaseComponentForm
from common.constants import API_TYPE_Q
from .toolkit import tools, configs

class GetToken(Component, SetupConfMixin):
    sys_name = configs.SYSTEM_NAME
    api_type = API_TYPE_Q

    class Form(BaseComponentForm):
        corpid = forms.CharField(label=u'企业ID', required=True)
        corpsecret = forms.CharField(label=u'应用的凭证密钥', required=True)

    def handle(self):
        client = tools.WEIXINClient(self.outgoing.http_client)
        result = client.get(path='/cgi-bin/gettoken', params=self.form_data)
        self.response.payload = result
